package GameLogic;

import org.joda.time.DateTime;

import Properties.props;

import com.sun.xml.internal.fastinfoset.sax.Properties;


public class CTDWave {
	
    /**
     * nextCreepTime: spawntime of Creeps in milliseconds
     */
    private int nextCreepTime;
	/**
	 * mode:
	 * 0: Normalmode (walkspeed not effected)
	 * 1: Hardmode (walkspeeed effected)
	 * 2: Expertmode (walkspeed and lifepoints effected)
	 */
	private int mode;
	private int goldPeJrKilJl;
	/**
	 * waves: maximum Waves 
	 */
	private int waves;
	/**
	 * aktWave: Current wave
	 */
	private int aktWave;
	private props constants = new props();
    /**
     * nextCreep: used to check if nextCreep can be spawn
     */
    private boolean nextCreep=false;
    /**
     * waypathID: Every Path and Creep got a WayPathID
     */
    private int waypathID;
	/**
	 * now: time now
	 */
	DateTime now = new DateTime();
    /**
     * nextWave: time of the nextWave
     */
    DateTime nextWave = new DateTime();
	private int goldPerKill;
        
    /**
	 * @return the goldPerKill
	 */
	public int getGoldPerKill() {
		return goldPerKill;
	}

	/**
	 * @param goldPerKill the goldPerKill to set
	 */
	public void setGoldPerKill(int goldPerKill) {
		this.goldPerKill = goldPerKill;
	}

	public int getNextCreepTime() {
        return nextCreepTime;
    }

    public void setNextCreepTime(int nextCreepTime) {
        this.nextCreepTime = nextCreepTime;
    }

    public int getWaypathID() {
        return waypathID;
    }

    public void setWaypathID(int waypathID) {
        this.waypathID = waypathID;
    }
	public int getMode() {
		return mode;
	}
	public void setMode(int mode) {
		this.mode = mode;
	}
	public int getWaves() {
		return waves;
	}
	public void setWaves(int waves) {
		this.waves = waves;
	}
	public int getAktWave() {
		return aktWave;
	}
	public void setAktWave(int aktWave) {
		this.aktWave = aktWave;
	}
        
        /**
         * checks if next Creep can be spawned and updates nextWave time
         * @return true if next Creep can be spawned otherwise false
         */
        public boolean checkCreep()
        {
                checkForCreep();
                if(nextCreep==true)
                    updateNext();
                return nextCreep;	
        }
	/**
	 * Adds a certain time to the current time 
	 */
	public void updateNext()
	{	
        nextWave = new DateTime();
		nextWave = nextWave.plusMillis((nextCreepTime - (nextCreepTime * mode)));	//(Calendar.MILLISECOND, nextCreepTime);	
	}
	/**
	 * Checks if the time now is after nextWave. Should only be used in this class.
	 * For checking if next Creep can be spawned use: boolean checkCreep()
	 */
	public void checkForCreep()
	{
	        now = new DateTime();
		if(now.isAfter(nextWave))
			nextCreep = true;
		else
			nextCreep = false;
                
	}
        /**
         * Adds a constant to nextWave. Normally its a relative big number otherwise the game starts immediately
         */
        public CTDWave()
        {
            nextWave.plusMillis(constants.startWave);
        }
}
